import java.util.Collection;

import javax.ejb.EJB;

import org.x4444.ProductManager;
import org.x4444.entity.Client;
import org.x4444.entity.Order;
import org.x4444.entity.OrderDetail;
import org.x4444.entity.OrderDetail2;
import org.x4444.entity.OrderDetailPK2;
import org.x4444.entity.Product;

public class Main {

	@EJB
	static ProductManager pm;

	public static void main(String[] args) {
		if (pm != null) {

			Client client = pm.getClient(1);
			System.out.println(client);
			Product pr = pm.getProduct(2);
			System.out.println(pr);
			Order ord = pm.getOrder(1);
			System.out.println(ord);
			OrderDetail ordDet = pm.getOrderDetail(1);
			System.out.println(ordDet);
			Collection<OrderDetail> details = ord.getOrderDetail();
			if (details != null) {
				// System.out.println(details == null);
				System.out.println(details.size());
				for (OrderDetail det : details) {
					System.out.println(det);
				}
			} else {
				System.out.println("details is null");
			}
			/*
			 * if (details != null) { for (OrderDetails det : details) {
			 * System.out.println(det); } }
			 */

			OrderDetail2 ordDet2 = pm.getOrderDetail2(new OrderDetailPK2(1,1));
			Product p2 = ordDet2.getProduct();
			Order o2 = ordDet2.getOrder();
			System.out.println("p2: " + p2);
			System.out.println("o2: " + o2);
			System.out.println("count2: " + ordDet2.getCount());
		} else {
			System.out.println("pm is null");
		}
	}
}